package com.anolesoft.yr.mbus.cont.entity;

import com.anolesoft.yr.mbus.contm.entity.ContmContent;
import com.anolesoft.yr.mbus.contm.entity.ContmMain;
import com.anolesoft.yr.mbus.contm.util.StringUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 合同实体内容表
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "cont_content")
public class ContContent implements Serializable {

    public ContContent(ContmContent contmContent, ContmMain contMain, ContContent parent){
        this.objuid = StringUtil.generateRundom32String();
        this.contMainUid = contMain.getObjuid();
        this.pageType = contmContent.getPageType();
        this.orderCode = contmContent.getOrderCode();
        this.itemType = contmContent.getItemType();
        this.parentUid = parent.getObjuid();
        this.content = contmContent.getContent();
        this.contmStyleUid = contmContent.getStyleItemUid();
        List<ContContent> contContents= new ArrayList<>();
       /* contmContent.getContmContentsTypeOfContent().forEach(a->{
            contContents.add(new ContContent(a,contMain,this)) ;
            contContentsContent.add(new ContContent(a,contMain,this)) ;
        });
        contmContent.getContmContentsTypeOfTitle().forEach(a->{
            contContents.add(new ContContent(a,contMain,this)) ;
            contContentsTitle.add(new ContContent(a,contMain,this));

        });*/
        this.contContents = contContents;
    }
    public ContContent createCopy(){
        return  ContContent.builder().objuid(StringUtil.generateRundom32String()).parentUid(parentUid).
                contmStyleUid(contmStyleUid).
                orderCode(orderCode).
                contMainUid(contMainUid).
                order(order).
                pageType(pageType).
                itemType(itemType).
                content(content).
                build();
    }
    private double order;
    private List<ContContent> contContents;

    private List<ContContent> contContentsTitle;

    private List<ContContent> contContentsContent;

    /**
     * 主键
     */
    @TableId(value = "objuid", type = IdType.INPUT)
    private String objuid;

    /**
     * 合同表主键
     */
    @TableField(value = "cont_main_uid")
    private String contMainUid;

    /**
     * 页类别
     */
    @TableField(value = "page_type")
    private String pageType;

    /**
     * 类型
     */
    @TableField(value = "item_type")
    private String itemType;

    /**
     * 序号
     */
    @TableField(value = "order_code")
    private Byte orderCode;

    /**
     * 父级
     */
    @TableField(value = "parent_uid")
    private String parentUid;

    /**
     * 内容
     */
    @TableField(value = "content")
    private String content;

    /**
     * 样式表主键
     */
    @TableField(value = "contm_style_uid")
    private String contmStyleUid;


    @TableField(value = "alias")
    private String alias;

    @TableField(exist = false)
    private Integer lvl;


    private static final long serialVersionUID = 1L;

    public static final String COL_OBJUID = "objuid";

    public static final String COL_CONT_MAIN_UID = "cont_main_uid";

    public static final String COL_PAGE_TYPE = "page_type";

    public static final String COL_ITEM_TYPE = "item_type";

    public static final String COL_ORDER_CODE = "order_code";

    public static final String COL_PARENT_UID = "parent_uid";

    public static final String COL_CONTENT = "content";

    public static final String COL_ALIAS = "alias";

    public static final String COL_CONTM_STYLE_UID = "contm_style_uid";
}